package www.cslc.com.Util;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public class ConfUtil {
	private static ConfigFileTools configFileTools = new ConfigFileTools(
			"conf\\system.properties");

	public ConfigFileTools getConfigFileTools() {
		return configFileTools;
	}

	@SuppressWarnings("static-access")
	public void setConfigFileTools(ConfigFileTools configFileTools) {

		this.configFileTools = configFileTools;
	}

	public String getRequestId() {

		return configFileTools.getValue("requestId", "0000000000001");
	}
    public static void updateLBSRequestId(String requestId) {
		
		DecimalFormat df = new DecimalFormat("0000000000000");
		
		configFileTools.updateProperties("requestId", df.format(Long.parseLong(requestId)));
		configFileTools.updatePropertiesFile();
	}
	public  String getDealerCode() {

		return configFileTools.getValue("dealerCode", "220001");
	}
	
	public  String getCountyCode() {

		return configFileTools.getValue("countyCode", "0000000000001");
	}
	
	public  String getAccountIP() {

		return configFileTools.getValue("accountIP", "0000000000001");
	}
	public   String getAccountPort() {

		return configFileTools.getValue("accountPort", "0000000000001");
	}
	
	public  String getHttps(){
		return configFileTools.getValue("https", "0");
	}
	
	public  String getLBSIP(){
		return configFileTools.getValue("LBSIP", "0");
	}
	
	public  String getLBSPort(){
		return configFileTools.getValue("LBSPort", "0");
	}
	public  String DBDriver(){
		return configFileTools.getValue("DBDriver", "jdbc:mysql://172.26.20.55:3306/cherry");
	}
	public  String DBUserName(){
		return configFileTools.getValue("DBUserName", "cherry");
	}
	public  String DBPassword(){
		return configFileTools.getValue("DBPassword", "cherry");
	}
	
	public  String getAccountNo(){
		return configFileTools.getValue("accountNo", "332000000000455");
	}
	
	public  String getBetSerialNo(){
		return configFileTools.getValue("betSerialNo", "4330101201506100000000000543");
	}
	
	public  String getLBSAccountNo(){
		return configFileTools.getValue("LBSaccountNo", "42201010000");
	}
	
	 public  void updateAccountNo(String value) {
			configFileTools.updateProperties("accountNo", value);
			configFileTools.updatePropertiesFile();
	}
	 
	 public  void updateBetSerialNo(String value) {
			configFileTools.updateProperties("betSerialNo", value);
			configFileTools.updatePropertiesFile();
	}
	
	
	
	
	
	
	
	
	
	
	
	
	public void updateRequestId(String requestId) {
		
		DecimalFormat df = new DecimalFormat("0000000000000");
		
		configFileTools.updateProperties("requestId", df.format(Long.parseLong(requestId)));
		configFileTools.updatePropertiesFile();
	}
	
	public  String getProvinceNo(){
		return configFileTools.getValue("provinceNo", "22");
	}
	
	public  String getInfoGWHFGameNo(){
		return configFileTools.getValue("infoGWHFGameNo", "206");
	}
	
	public  String getInfoGWHotLineGameNo(){
		return configFileTools.getValue("infoGWHotLineGameNo", "35");
	}
	
	public  String getInfoGWUserName(){
		return configFileTools.getValue("infoGWUserName", "ztc");
	}
	
	public  String getInfoGWPassword(){
		return configFileTools.getValue("infoGWPassword", "ztc");
	}
	
	public  String getInfoGWURL(){
		return configFileTools.getValue("infoGWURL",
				"http://172.26.21.55:8089/Infogw/infogwservice.asmx?wsdl");
	}
	static DateFormat df = new SimpleDateFormat("yyyyMMdd");
	static ConfUtil signUtil = new ConfUtil();
	static DecimalFormat df2 = new DecimalFormat("0000000000000");
	public synchronized static String getRequestid(String channelCode, String agentCode) {
		String str1 = signUtil.getRequestId();
		if ("9999999999999".equals(str1))
			str1 = "0000000000001";
		
		String str2 = df2.format((Long.parseLong(str1) + 1));
		signUtil.updateRequestId(str2);
		return channelCode + agentCode + df.format(new Date(System.currentTimeMillis())) + str2;

	}
}